home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / src / libgrx.h < prev    next >
Text File  |  1993-12-06  |  25KB  |  718 lines

  1. /**
  2.  ** LIBGRX.H
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #ifndef _LIBGRX_H_
  25. #define _LIBGRX_H_
  26.  
  27. #ifndef NULL
  28. # define NULL        0
  29. #endif
  30.  
  31. #ifndef TRUE
  32. # define TRUE        1
  33. # define FALSE        0
  34. #endif
  35.  
  36. /*
  37.  * get rid of these stupid keywords (Thanks Intel....)
  38.  */
  39. #if defined(__GNUC__) && !defined(near)
  40. # define near
  41. # define far
  42. # define huge
  43. #endif
  44.  
  45.  
  46. /* ================================================================== */
  47. /*               VERSION SELECTION                  */
  48. /* ================================================================== */
  49.  
  50. /*
  51.  * The GRXPLANES macro selects the version of the library to be compiled.
  52.  * An adapter support is included in the library if its corresponding bit
  53.  * is set:
  54.  *    1:    1 plane (Hercules) version (drivers TBD)
  55.  *    4:    4 plane (EGA VGA 16 color) version
  56.  *    8:    8 plane (VGA 256 color) version
  57.  *     16:     16 plane (VGA w/ HICOLOR DAC) version
  58.  *     32:    8 plane MODE X - like memory organization (drivers TBD)
  59.  *     64:    8 plane IBM 8514A and compatibles
  60.  *    128:    8 plane S3 graphics accelerator
  61.  *                 :
  62.  *                 : (future extensions)
  63.  *                 :
  64.  *    255:      all versions
  65.  *    239:      all versions but the 32K color VGA
  66.  *          etc...
  67.  * Notes:
  68.  *   The 16 plane version can not be compiled using Turbo C.
  69.  *   Selecting a single mode version will result in a slightly smaller and
  70.  *    faster (faster is true especially for the 256 and 32K color VGA modes)
  71.  *    library.
  72.  *   See also the notes about the video drivers needed for this library
  73.  */
  74.  
  75. #define MODE_X        32
  76. #define MODE_8514A    64
  77. #define MODE_S3        128
  78.  
  79. #if (GRXPLANES == 0) || (GRXPLANES == 0xff)
  80. # undef GRXPLANES
  81. #endif
  82.  
  83. #ifndef GRXPLANES
  84. # ifdef __TURBOC__
  85. #   define GRXPLANES    (1 | 4 | 8 | MODE_X | MODE_8514A | MODE_S3)
  86. # endif
  87. # ifdef __GNUC__
  88. #   define GRXPLANES    (1 | 4 | 8 | 16 | MODE_X | MODE_8514A | MODE_S3)
  89. # endif
  90. #endif
  91.  
  92. #if defined(__TURBOC__) && (GRXPLANES & 16)
  93. # error Turbo C does not support the HiColor mode
  94. #endif
  95.  
  96.  
  97. /* ================================================================== */
  98. /*            COMPILATION OPTIONS                  */
  99. /* ================================================================== */
  100.  
  101. /*
  102.  * _MAXVIDPLANESIZE
  103.  *    If set use this value as the maximum size for a bitplane in video RAM.
  104.  *    Set it to 1M (limit by GO32) in 32-bit mode, to 64K for the 16-bit
  105.  *    versions. GO32 1.11+ also supports 16MB paging areas -- define
  106.  *    _MAXBIGVIDPLSIZE as this limit.
  107.  */
  108.  
  109. #ifdef __TURBOC__
  110. # define _MAXVIDPLANESIZE  (1024UL*64)
  111. #endif
  112.  
  113. #ifdef __GNUC__
  114. # define _MAXVIDPLANESIZE  (1024UL*1024UL*1)
  115. # define _MAXBIGVIDPLSIZE  (1024UL*1024UL*16)
  116. #endif
  117.  
  118. /*
  119.  * _MAXMEMPLANESIZE
  120.  *    If set use this value as the maximum size for a bitplane in memory.
  121.  *    (Not needed in 32-bit mode, set it to somewhat less than 64K for
  122.  *    the 16-bit versions. Max value is 64K - 4*16 because of the way the
  123.  *    offset to the bitplanes is calculated in 16 color modes.)
  124.  */
  125.  
  126. #ifdef __TURBOC__
  127. # define _MAXMEMPLANESIZE  (1020UL*64)
  128. #endif
  129.  
  130. /*
  131.  * _INLINE256
  132.  *    If set, then the appropriate 256 color primitives will be
  133.  *    expanded inline. (set pixel, read pixel)
  134.  *    Also changes the method of pixel address calculations:
  135.  *    instead of a packed long containing (x,y) pairs, true
  136.  *    pixel addresses (base + y*xsize + x) will be calculated inline.
  137.  *    This option is only effective when compiling a 256 color
  138.  *    single mode library.
  139.  */
  140. #if (GRXPLANES == 8)
  141. # ifdef __TURBOC__
  142. #   define _INLINE256        /* won't work beyond 320x200 !!! */
  143. # endif
  144. # ifdef __GNUC__
  145. #   define _INLINE256
  146. # endif
  147. #endif
  148.  
  149. /*
  150.  * _INLINE32K
  151.  *    If set, then the appropriate 32K color primitives will be
  152.  *    expanded inline. (set pixel, read pixel)
  153.  *    Also changes the method of pixel address calculations:
  154.  *    instead of a packed long containing (x,y) pairs, true
  155.  *    pixel addresses (base + y*xsize + x) will be calculated inline.
  156.  *    This option is only effective when compiling a 256 color
  157.  *    single mode library.
  158.  */
  159. #if (GRXPLANES == 16)
  160. # ifdef __GNUC__
  161. #   define _INLINE32K
  162. # endif
  163. #endif
  164.  
  165.  
  166. /* ================================================================== */
  167. /*        PACK/UNPACK TWO SHORTS INTO A LONG INTEGER              */
  168. /* ================================================================== */
  169.  
  170. #ifdef __GNUC__
  171. # define _PACK2SHORTS(h,l)    (((h) << 16) | (l))
  172. # define _UPPERWORD(x)        ((int)(((unsigned long)(x)) >> 16))
  173. # define _LOWERWORD(x)        ((int)((unsigned short)(x)))
  174. #endif
  175.  
  176. #ifdef __TURBOC__
  177. # define _PACK2SHORTS(h,l)    ((long)((void _seg *)(h) + (void near *)(l)))
  178. # define _UPPERWORD(x)        ((unsigned int)(void _seg *)(void far *)(x))
  179. # define _LOWERWORD(x)        ((unsigned int)(x))
  180. #endif
  181.  
  182.  
  183. /* ================================================================== */
  184. /*        INTERNALLY USED GLOBAL VARIABLES AND FUNCTIONS          */
  185. /* ================================================================== */
  186.  
  187. extern  GrContext _GrContext;        /* current graphics context */
  188. extern  GrContext _GrVidPage;        /* the whole screen */
  189.  
  190. extern  int  _GrCurrentMode;        /* current video mode */
  191. extern  int  _GrCanBcopyInBlit;        /* separate R/W pages in adapter */
  192. extern  int  _GrBigFrameBuffer;        /* set if frame buffer > 64K */
  193. extern  int  _GrNumColors;        /* number of colors */
  194. extern  int  _GrFreeColors;        /* number of free colors */
  195. extern  int  _GrAdapterType;        /* type of video adapter */
  196. extern  int  _GrDriverIndex;        /* low-level video routine selector */
  197. extern  int  _GrRGBcolorMode;        /* set if VGA DAC inited to RGB mode */
  198. extern  int  _GrRdOnlyOffset;        /* add for read-only video page */
  199. extern  int  _GrWrOnlyOffset;        /* add for write-only video page */
  200.  
  201. extern  int  _GrScreenX;        /* screen width  */
  202. extern  int  _GrScreenY;        /* screen height */
  203.  
  204. extern  char _GrMouseDrawn;        /* set if mouse drawn */
  205. extern  char _GrMouseCheck;        /* set if mouse blocking needed */
  206.  
  207. extern  int  (*_GrMouseBlock)(GrContext *c,int x1,int y1,int x2,int y2);
  208. extern  void (*_GrMouseUnBlock)(int);
  209. extern  void (*_GrMouseUnInit)(void);
  210.  
  211. /*
  212.  * internal scan line fill and single pixel wide line draw and pixel fill
  213.  * routines used by several thick line and filled solid primitives
  214.  */
  215. typedef void (*_GrScanLineProc)(int x1,int x2,int y,void *fillarg);
  216. typedef void (*_GrLineDrawProc)(int x1,int y1,int x2,int y2,void *fillarg);
  217. typedef void (*_GrPixelDrawProc)(int x,int y,void *fillarg);
  218.  
  219. extern  void _GrFillSolidScanLine(int x1,int x2,int y,void *arg);
  220. extern  void _GrFillPatternedScanLine(int x1,int x2,int y,void *arg);
  221.  
  222. extern  void _GrDrawSolidLine(int x1,int y1,int x2,int y2,void *arg);
  223. extern  void _GrDrawSolidPixel(int x,int y,void *arg);
  224.  
  225. extern  void _GrDummySolidLine(int x1,int y1,int x2,int y2,void *arg);
  226. extern  void _GrDummySolidPixel(int x,int y,void *arg);
  227.  
  228. #define _GrDrawPatternedLine    ((_GrLineDrawProc)GrPatternFilledLine)
  229. #define _GrDrawPatternedPixel    ((_GrPixelDrawProc)GrPatternFilledPlot)
  230. #define _GrDummyPatternedLine    _GrDummySolidLine
  231. #define _GrDummyPatternedPixel  _GrDummySolidPixel
  232.  
  233. /*
  234.  * internal polygon, circle and thick line scan/draw routines
  235.  */
  236. extern void _GrDrawPolygon(int n,int pt[][2],
  237.     int do_close,
  238.     int is_XOR_color,
  239.     _GrPixelDrawProc pixelproc,
  240.     _GrLineDrawProc  lineproc,
  241.     void *fillarg
  242. );
  243.  
  244. extern void _GrScanConvexPoly(int n,int pt[][2],
  245.     int is_XOR_color,
  246.     _GrPixelDrawProc pixelproc,
  247.     _GrLineDrawProc  borderproc,
  248.     _GrScanLineProc  scanfillproc,
  249.     void *fillarg
  250. );
  251.  
  252. extern void _GrScanPolygon(int n,int pt[][2],
  253.     int is_XOR_color,
  254.     _GrPixelDrawProc pixelproc,
  255.     _GrLineDrawProc  borderproc,
  256.     _GrScanLineProc  scanfillproc,
  257.     void *fillarg
  258. );
  259.  
  260. extern void _GrScanEllipse(
  261.     int x,int y,int a,int b,
  262.     int filled,
  263.     int is_XOR_color,
  264.     _GrPixelDrawProc pixelproc,
  265.     _GrLineDrawProc  borderproc,
  266.     _GrScanLineProc  scanfillproc,
  267.     void *fillarg
  268. );
  269.  
  270. #define IS_XOR_COLOR(c)        (C_OPER(c) == C_XOR)
  271. #define IS_XOR_PATTERN(p)    ((p)->gp_ispixmap ?                    \
  272.     IS_XOR_COLOR((p)->gp_pxp_oper) :                            \
  273.     ((IS_XOR_COLOR((p)->gp_bmp_fgcolor) && ((p)->gp_bmp_fgcolor != GrNOCOLOR)) ||   \
  274.      (IS_XOR_COLOR((p)->gp_bmp_bgcolor) && ((p)->gp_bmp_bgcolor != GrNOCOLOR)))        \
  275. )
  276.  
  277. /*
  278.  * ellipe and ellipse arc point list generators for cases which are not
  279.  * handled by the ellipse scan algorithm. (arc and thick line cases)
  280.  */
  281. extern  int  _GrGenerateEllipse(int pt[][2],int cx,int cy,int rx,int ry);
  282. extern  int  _GrGenerateEllipseArc(int pt[][2],int cx,int cy,int rx,int ry,int start,int end,int filled);
  283. #ifdef __TURBOC__
  284. #define MAX_ELLIPSE_PTS 256
  285. #endif
  286. #ifdef __GNUC__
  287. #define MAX_ELLIPSE_PTS 1024
  288. #endif
  289.  
  290. /* ================================================================== */
  291. /*               CONTEXT ACCESS MACROS                  */
  292. /* ================================================================== */
  293.  
  294. #define GC            GrContext
  295. #define GV            GrVidRAM
  296.  
  297. #define GCM_INVALID        0
  298. #define GCM_MYMEMORY        1        /* set if my context memory */
  299. #define GCM_MYCONTEXT        2        /* set if my context structure */
  300.  
  301. #define XMAX(c)            ((c)->gc_xmax)
  302. #define YMAX(c)            ((c)->gc_ymax)
  303.  
  304. #define XLO(c)            ((c)->gc_xcliplo)
  305. #define XHI(c)            ((c)->gc_xcliphi)
  306. #define YLO(c)            ((c)->gc_ycliplo)
  307. #define YHI(c)            ((c)->gc_ycliphi)
  308.  
  309. #ifdef _INLINE256
  310. # define BASE_ADDRESS(c)    ((long)((c)->gc_baseaddr))
  311. # define LINE_OFFSET(c)        ((c)->gc_lineoffset)
  312. # define PIX_OFFS(c,x,y)    ((unsigned)(((y) * LINE_OFFSET(c)) + (x)))
  313. # define PIX_ADDR(c,x,y)    ((c)->gc_frameaddr + PIX_OFFS(c,x,y))
  314. # define PIXEL_SIZE        1
  315. #elif defined(_INLINE32K)
  316. # define BASE_ADDRESS(c)    ((long)((c)->gc_baseaddr))
  317. # define LINE_OFFSET(c)        ((c)->gc_lineoffset)
  318. # define PIX_OFFS(c,x,y)    ((unsigned)(((y) * LINE_OFFSET(c)) + ((x) << 1)))
  319. # define PIX_ADDR(c,x,y)    ((c)->gc_frameaddr + PIX_OFFS(c,x,y))
  320. # define PIXEL_SIZE        2
  321. #else
  322. # define BASE_ADDRESS(c)    (0L)
  323. # define LINE_OFFSET(c)        (0x10000L)
  324. # define PIX_OFFS(c,x,y)    _PACK2SHORTS(y,x)
  325. # define PIX_ADDR(c,x,y)    ((c)->gc_frameaddr + PIX_OFFS(c,x,y))
  326. # define COORD_X(coord)        _LOWERWORD(coord)
  327. # define COORD_Y(coord)        _UPPERWORD(coord)
  328. # define PIXEL_SIZE        1
  329. #endif
  330.  
  331.  
  332. /* ================================================================== */
  333. /*            CURRENT CONTEXT ACCESS MACROS              */
  334. /* ================================================================== */
  335.  
  336. #define CURC        (&_GrContext)
  337. #define SCREEN        (&_GrVidPage)
  338.  
  339. #define _GrMaxX        XMAX(CURC)
  340. #define _GrMaxY        YMAX(CURC)
  341. #define _GrSizeX    (_GrMaxX + 1)
  342. #define _GrSizeY    (_GrMaxY + 1)
  343.  
  344. #define _GrLoX        XLO(CURC)
  345. #define _GrLoY        YLO(CURC)
  346. #define _GrHiX        XHI(CURC)
  347. #define _GrHiY        YHI(CURC)
  348.  
  349. #define PIXEL_OFFS(x,y) PIX_OFFS(CURC,x,y)
  350. #define PIXEL_ADDR(x,y) PIX_ADDR(CURC,x,y)
  351.  
  352.  
  353. /* ================================================================== */
  354. /*            COLOR MANIPULATION MACROS                  */
  355. /* ================================================================== */
  356.  
  357. #ifdef __TURBOC__
  358. # define C_SET        0        /* color operation flags (XOR...) */
  359. # define C_XOR        (GrXOR >> 8)
  360. # define C_OR        (GrOR  >> 8)
  361. # define C_AND        (GrAND >> 8)
  362. # define C_COLOR    0xff        /* masks out operation flags */
  363. # define C_SIMPLE(c)    (((c) & 0x300) == 0)
  364. # define C_OPER(c)    (((c) >> 8) & 3)
  365. # define C_OPER2(c)    (((c) >> 7) & 6)
  366. #endif
  367.  
  368. #ifdef __GNUC__
  369. # define C_SET        0        /* color operation flags (XOR...) */
  370. # define C_XOR        (GrXOR >> 24)
  371. # define C_OR        (GrOR  >> 24)
  372. # define C_AND        (GrAND >> 24)
  373. # define C_COLOR    0xffffff    /* masks out operation flags */
  374. # define C_SIMPLE(c)    (((c) & 0x3000000) == 0)
  375. # define C_OPER(c)    (((c) >> 24) & 3)
  376. # define C_OPER2(c)    (((c) >> 23) & 6)
  377. #endif
  378.  
  379. #define  C_SET2        0
  380. #define  C_XOR2        (C_XOR << 1)
  381. #define  C_OR2        (C_OR  << 1)
  382. #define  C_AND2        (C_AND << 1)
  383.  
  384.  
  385. /* ================================================================== */
  386. /*             UTILITY MACROS                      */
  387. /* ================================================================== */
  388.  
  389. #define MIN(a,b)    (((a) < (b)) ? (a) : (b))
  390. #define MAX(a,b)    (((a) > (b)) ? (a) : (b))
  391. #define IABS(x)        (((x) < 0) ?  -(x) : (x))
  392.  
  393. /*
  394.  * exchange two integers
  395.  */
  396. #define EXCHG(a,b) do {                            \
  397.     int __temp__ = (a);                            \
  398.     (a) = (b);                                \
  399.     (b) = __temp__;                            \
  400. } while(0)
  401.  
  402. /*
  403.  * sort two values
  404.  */
  405. #define SORT2(a,b) do {                            \
  406.     if((a) > (b)) EXCHG(a,b);                        \
  407. } while(0)
  408.  
  409. /*
  410.  * conditionally remove/restore mouse cursor for drawing primitives
  411.  */
  412. #define MOUSE_FLAG  char _mouse_block_flag_ = FALSE
  413.  
  414. #define MOUSE_BLOCK(cxt,x1,y1,x2,y2) do {                \
  415.     _mouse_block_flag_ = FALSE;                        \
  416.     if(_GrMouseCheck) {                            \
  417.     _mouse_block_flag_ = (*_GrMouseBlock)(cxt,x1,y1,x2,y2);        \
  418.     }                                    \
  419. } while(0);
  420.  
  421. #define MOUSE_UNBLOCK() do {                        \
  422.     if(_mouse_block_flag_) (*_GrMouseUnBlock)(_mouse_block_flag_);    \
  423.     _mouse_block_flag_ = FALSE;                        \
  424. } while(0);
  425.  
  426.  
  427. /* ================================================================== */
  428. /*           MODE-DEPENDENT LOW-LEVEL DRIVER FUNCTIONS          */
  429. /* ================================================================== */
  430.  
  431. /*
  432.  * Share most S3 and 8514A low-level drivers for now. Later the S3 could
  433.  * be optimized by using mixed direct frame buffer access and 8514/A-style
  434.  * programming where appropriate. Example:
  435.  *  _GrPSSetPixel  could be faster using direct access
  436.  *  _GrPSDrawLine  is faster with 8514/A style programming
  437.  */
  438. void _GrP4Init(int memsize);
  439. void _GrPXInit(int memsize);
  440. void _GrP8Init(int accesstype);
  441.  
  442. int  _GrP1ReadPixel(GC *cxt,long addr);
  443. int  _GrP4ReadPixel(GC *cxt,long addr);
  444. int  _GrP8ReadPixel(GC *cxt,long addr);
  445. int  _GrPHReadPixel(GC *cxt,long addr);
  446. int  _GrPXReadPixel(GC *cxt,long addr);
  447. int  _GrPIReadPixel(GC *cxt,long addr);
  448. #define _GrPSReadPixel _GrPIReadPixel
  449.  
  450. void _GrP1SetPixel(long addr,int color);
  451. void _GrP4SetPixel(long addr,int color);
  452. void _GrP8SetPixel(long addr,int color);
  453. void _GrPHSetPixel(long addr,int color);
  454. void _GrPXSetPixel(long addr,int color);
  455. void _GrPISetPixel(long addr,int color);
  456. #define _GrPSSetPixel _GrPISetPixel
  457.  
  458. void _GrP1SetPixRow(long addr,int color,int width);
  459. void _GrP4SetPixRow(long addr,int color,int width);
  460. void _GrP8SetPixRow(long addr,int color,int width);
  461. void _GrPHSetPixRow(long addr,int color,int width);
  462. void _GrPXSetPixRow(long addr,int color,int width);
  463. void _GrPISetPixRow(long addr,int color,int width);
  464. #define _GrPSSetPixRow _GrPISetPixRow
  465.  
  466. void _GrP1SetPixColumn(long addr,int color,int height);
  467. void _GrP4SetPixColumn(long addr,int color,int height);
  468. void _GrP8SetPixColumn(long addr,int color,int height);
  469. void _GrPHSetPixColumn(long addr,int color,int height);
  470. void _GrPXSetPixColumn(long addr,int color,int height);
  471. void _GrPISetPixColumn(long addr,int color,int height);
  472. #define _GrPSSetPixColumn _GrPISetPixColumn
  473.  
  474. void _GrP1SetPixBlock(long addr,int color,int w,int h);
  475. void _GrP4SetPixBlock(long addr,int color,int w,int h);
  476. void _GrP8SetPixBlock(long addr,int color,int w,int h);
  477. void _GrPHSetPixBlock(long addr,int color,int w,int h);
  478. void _GrPXSetPixBlock(long addr,int color,int w,int h);
  479. void _GrPISetPixBlock(long addr,int color,int w,int h);
  480. #define _GrPSSetPixBlock _GrPISetPixBlock
  481.  
  482. void _GrP1DrawLine(long addr,int color,int dx,int dy);
  483. void _GrP4DrawLine(long addr,int color,int dx,int dy);
  484. void _GrP8DrawLine(long addr,int color,int dx,int dy);
  485. void _GrPHDrawLine(long addr,int color,int dx,int dy);
  486. void _GrPXDrawLine(long addr,int color,int dx,int dy);
  487. void _GrPIDrawLine(long addr,int color,int dx,int dy);
  488. #define _GrPSDrawLine _GrPIDrawLine
  489.  
  490. void _GrP1DrawChar(long addr,int w,int h,char far *bits,int fg,int bg);
  491. void _GrP4DrawChar(long addr,int w,int h,char far *bits,int fg,int bg);
  492. void _GrP8DrawChar(long addr,int w,int h,char far *bits,int fg,int bg);
  493. void _GrPHDrawChar(long addr,int w,int h,char far *bits,int fg,int bg);
  494. void _GrPXDrawChar(long addr,int w,int h,char far *bits,int fg,int bg);
  495. void _GrPIDrawChar(long addr,int w,int h,char far *bits,int fg,int bg);
  496. void _GrPSDrawChar(long addr,int w,int h,char far *bits,int fg,int bg);
  497.  
  498. void _GrP1PixCopy(GC *dst,long daddr,GC *src,long saddr,int w,int h,int op);
  499. void _GrP4PixCopy(GC *dst,long daddr,GC *src,long saddr,int w,int h,int op);
  500. void _GrP8PixCopy(GC *dst,long daddr,GC *src,long saddr,int w,int h,int op);
  501. void _GrPHPixCopy(GC *dst,long daddr,GC *src,long saddr,int w,int h,int op);
  502. void _GrPXPixCopy(GC *dst,long daddr,GC *src,long saddr,int w,int h,int op);
  503. void _GrPIPixCopy(GC *dst,long daddr,GC *src,long saddr,int w,int h,int op);
  504. #define _GrPSPixCopy _GrPIPixCopy
  505.  
  506. void _GrP1FillPattern(int x,int y,int width,GrPattern *p);
  507. void _GrP4FillPattern(int x,int y,int width,GrPattern *p);
  508. void _GrP8FillPattern(int x,int y,int width,GrPattern *p);
  509. void _GrPHFillPattern(int x,int y,int width,GrPattern *p);
  510. void _GrPXFillPattern(int x,int y,int width,GrPattern *p);
  511. void _GrPIFillPattern(int x,int y,int width,GrPattern *p);
  512. void _GrPSFillPattern(int x,int y,int width,GrPattern *p);
  513.  
  514.  
  515. /* ================================================================== */
  516. /*        SELECT LOW-LEVEL VIDEO ACCESS ROUTINES              */
  517. /* ================================================================== */
  518.  
  519. #if GRXPLANES == 1
  520. # define _GrReadPixel(c,a)        _GrP1ReadPixel(c,a)
  521. # define _GrSetPixel(a,p)        _GrP1SetPixel(a,p)
  522. # define _GrSetPixRow(a,p,w)        _GrP1SetPixRow(a,p,w)
  523. # define _GrSetPixColumn(a,p,h)        _GrP1SetPixColumn(a,p,h)
  524. # define _GrSetPixBlock(a,p,w,h)    _GrP1SetPixBlock(a,p,w,h)
  525. # define _GrDrawLine(a,p,dx,dy)        _GrP1DrawLine(a,p,dx,dy)
  526. # define _GrDrawChar(a,w,h,b,fg,bg)    _GrP1DrawChar(a,w,h,b,fg,bg)
  527. # define _GrPixCopy(d,da,s,sa,w,h,o)    _GrP1PixCopy(d,da,s,sa,w,h,o)
  528. # define _GrFillPattern(x,y,wdt,p)    _GrP1FillPattern(x,y,wdt,p)
  529. # define _SINGLE_MODE_
  530. #endif
  531.  
  532. #if GRXPLANES == 4
  533. # define _GrReadPixel(c,a)        _GrP4ReadPixel(c,a)
  534. # define _GrSetPixel(a,p)        _GrP4SetPixel(a,p)
  535. # define _GrSetPixRow(a,p,w)        _GrP4SetPixRow(a,p,w)
  536. # define _GrSetPixColumn(a,p,h)        _GrP4SetPixColumn(a,p,h)
  537. # define _GrSetPixBlock(a,p,w,h)    _GrP4SetPixBlock(a,p,w,h)
  538. # define _GrDrawLine(a,p,dx,dy)        _GrP4DrawLine(a,p,dx,dy)
  539. # define _GrDrawChar(a,w,h,b,fg,bg)    _GrP4DrawChar(a,w,h,b,fg,bg)
  540. # define _GrPixCopy(d,da,s,sa,w,h,o)    _GrP4PixCopy(d,da,s,sa,w,h,o)
  541. # define _GrFillPattern(x,y,wdt,p)    _GrP4FillPattern(x,y,wdt,p)
  542. # define _SINGLE_MODE_
  543. #endif
  544.  
  545. #if GRXPLANES == 8
  546. # ifdef _INLINE256
  547. #   define _GrReadPixel(c,a)        (*(unsigned char far *)(a))
  548. #   define _GrSetPixel(a,p) do {                    \
  549.     register unsigned char far *_aa_ = (unsigned char far *)(a);    \
  550.     register unsigned int _pp_ = (unsigned int)(p);            \
  551.     switch(C_OPER(_pp_)) {                        \
  552.         case C_XOR: *_aa_ ^= _pp_; break;                \
  553.         case C_OR:  *_aa_ |= _pp_; break;                \
  554.         case C_AND: *_aa_ &= _pp_; break;                \
  555.         default:    *_aa_  = _pp_; break;                \
  556.     }                                \
  557.     } while(0)
  558. # else
  559. #   define _GrReadPixel(c,a)        _GrP8ReadPixel(c,a)
  560. #   define _GrSetPixel(a,p)        _GrP8SetPixel(a,p)
  561. # endif
  562. # define _GrSetPixRow(a,p,w)        _GrP8SetPixRow(a,p,w)
  563. # define _GrSetPixColumn(a,p,h)        _GrP8SetPixColumn(a,p,h)
  564. # define _GrSetPixBlock(a,p,w,h)    _GrP8SetPixBlock(a,p,w,h)
  565. # define _GrDrawLine(a,p,dx,dy)        _GrP8DrawLine(a,p,dx,dy)
  566. # define _GrDrawChar(a,w,h,b,fg,bg)    _GrP8DrawChar(a,w,h,b,fg,bg)
  567. # define _GrPixCopy(d,da,s,sa,w,h,o)    _GrP8PixCopy(d,da,s,sa,w,h,o)
  568. # define _GrFillPattern(x,y,wdt,p)    _GrP8FillPattern(x,y,wdt,p)
  569. # define _SINGLE_MODE_
  570. #endif
  571.  
  572. #if GRXPLANES == 16
  573. # ifdef _INLINE32K
  574. #   define _GrReadPixel(c,a)        (*(unsigned short far *)(a))
  575. #   define _GrSetPixel(a,p) do {                    \
  576.     register unsigned short far *_aa_ = (unsigned short far *)(a);  \
  577.     register unsigned int _pp_ = (unsigned int)(p);            \
  578.     switch(C_OPER(_pp_)) {                        \
  579.         case C_XOR: *_aa_ ^= _pp_; break;                \
  580.         case C_OR:  *_aa_ |= _pp_; break;                \
  581.         case C_AND: *_aa_ &= _pp_; break;                \
  582.         default:    *_aa_  = _pp_; break;                \
  583.     }                                \
  584.     } while(0)
  585. # else
  586. #   define _GrReadPixel(c,a)        _GrPHReadPixel(c,a)
  587. #   define _GrSetPixel(a,p)        _GrPHSetPixel(a,p)
  588. # endif
  589. # define _GrSetPixRow(a,p,w)        _GrPHSetPixRow(a,p,w)
  590. # define _GrSetPixColumn(a,p,h)        _GrPHSetPixColumn(a,p,h)
  591. # define _GrSetPixBlock(a,p,w,h)    _GrPHSetPixBlock(a,p,w,h)
  592. # define _GrDrawLine(a,p,dx,dy)        _GrPHDrawLine(a,p,dx,dy)
  593. # define _GrDrawChar(a,w,h,b,fg,bg)    _GrPHDrawChar(a,w,h,b,fg,bg)
  594. # define _GrPixCopy(d,da,s,sa,w,h,o)    _GrPHPixCopy(d,da,s,sa,w,h,o)
  595. # define _GrFillPattern(x,y,wdt,p)    _GrPHFillPattern(x,y,wdt,p)
  596. # define _SINGLE_MODE_
  597. #endif
  598.  
  599. #if GRXPLANES == MODE_X
  600. # define _GrReadPixel(c,a)        _GrPXReadPixel(c,a)
  601. # define _GrSetPixel(a,p)        _GrPXSetPixel(a,p)
  602. # define _GrSetPixRow(a,p,w)        _GrPXSetPixRow(a,p,w)
  603. # define _GrSetPixColumn(a,p,h)        _GrPXSetPixColumn(a,p,h)
  604. # define _GrSetPixBlock(a,p,w,h)    _GrPXSetPixBlock(a,p,w,h)
  605. # define _GrDrawLine(a,p,dx,dy)        _GrPXDrawLine(a,p,dx,dy)
  606. # define _GrDrawChar(a,w,h,b,fg,bg)    _GrPXDrawChar(a,w,h,b,fg,bg)
  607. # define _GrPixCopy(d,da,s,sa,w,h,o)    _GrPXPixCopy(d,da,s,sa,w,h,o)
  608. # define _GrFillPattern(x,y,wdt,p)    _GrPXFillPattern(x,y,wdt,p)
  609. # define _SINGLE_MODE_
  610. #endif
  611.  
  612. #if GRXPLANES == MODE_8514A
  613. # define _GrReadPixel(c,a)        _GrPIReadPixel(c,a)
  614. # define _GrSetPixel(a,p)        _GrPISetPixel(a,p)
  615. # define _GrSetPixRow(a,p,w)        _GrPISetPixRow(a,p,w)
  616. # define _GrSetPixColumn(a,p,h)        _GrPISetPixColumn(a,p,h)
  617. # define _GrSetPixBlock(a,p,w,h)    _GrPISetPixBlock(a,p,w,h)
  618. # define _GrDrawLine(a,p,dx,dy)        _GrPIDrawLine(a,p,dx,dy)
  619. # define _GrDrawChar(a,w,h,b,fg,bg)    _GrPIDrawChar(a,w,h,b,fg,bg)
  620. # define _GrPixCopy(d,da,s,sa,w,h,o)    _GrPIPixCopy(d,da,s,sa,w,h,o)
  621. # define _GrFillPattern(x,y,wdt,p)    _GrPIFillPattern(x,y,wdt,p)
  622. # define _SINGLE_MODE_
  623. #endif
  624.  
  625. #if GRXPLANES == MODE_S3
  626. # define _GrReadPixel(c,a)        _GrPSReadPixel(c,a)
  627. # define _GrSetPixel(a,p)        _GrPSSetPixel(a,p)
  628. # define _GrSetPixRow(a,p,w)        _GrPSSetPixRow(a,p,w)
  629. # define _GrSetPixColumn(a,p,h)        _GrPSSetPixColumn(a,p,h)
  630. # define _GrSetPixBlock(a,p,w,h)    _GrPSSetPixBlock(a,p,w,h)
  631. # define _GrDrawLine(a,p,dx,dy)        _GrPSDrawLine(a,p,dx,dy)
  632. # define _GrDrawChar(a,w,h,b,fg,bg)    _GrPSDrawChar(a,w,h,b,fg,bg)
  633. # define _GrPixCopy(d,da,s,sa,w,h,o)    _GrPSPixCopy(d,da,s,sa,w,h,o)
  634. # define _GrFillPattern(x,y,wdt,p)    _GrPSFillPattern(x,y,wdt,p)
  635. # define _SINGLE_MODE_
  636. #endif
  637.  
  638. #define ReadPixelIndex        0
  639. #define SetPixelIndex        1
  640. #define SetPixRowIndex        2
  641. #define SetPixColumnIndex    3
  642. #define SetPixBlockIndex    4
  643. #define DrawLineIndex        5
  644. #define DrawCharIndex        6
  645. #define PixCopyIndex        7
  646. #define FillPatternIndex    8
  647.  
  648. #define NumOfHandlers        9
  649. typedef void (*handler)(void);
  650.  
  651. #ifndef _SINGLE_MODE_
  652.   extern int  (*_GrReadPixel)(GC *,long);
  653.   extern void (*_GrSetPixel)(long,int);
  654.   extern void (*_GrSetPixRow)(long,int,int);
  655.   extern void (*_GrSetPixColumn)(long,int,int);
  656.   extern void (*_GrSetPixBlock)(long,int,int,int);
  657.   extern void (*_GrDrawLine)(long,int,int,int);
  658.   extern void (*_GrDrawChar)(long,int,int,char far *,int,int);
  659.   extern void (*_GrPixCopy)(GC *,long,GC *,long,int,int,int);
  660.   extern void (*_GrFillPattern)(int,int,int,GrPattern *);
  661.   extern handler  _GrResetValues[];
  662.   extern handler *_GrResetAddresses[];
  663. #endif
  664.  
  665. #if (GRXPLANES & 1) && defined(WANT_TO_INCLUDE_INCOMPLETE_MODES)
  666. # define USE_DRIVER_1(func)    func
  667. #else
  668. # define USE_DRIVER_1(func)    _GrVoidDriver
  669. #endif
  670.  
  671. #if (GRXPLANES & 4)
  672. # define USE_DRIVER_4(func)    func
  673. #else
  674. # define USE_DRIVER_4(func)    _GrVoidDriver
  675. #endif
  676.  
  677. #if (GRXPLANES & 8)
  678. # define USE_DRIVER_8(func)    func
  679. #else
  680. # define USE_DRIVER_8(func)    _GrVoidDriver
  681. #endif
  682.  
  683. #if (GRXPLANES & 16)
  684. # define USE_DRIVER_H(func)    func
  685. #else
  686. # define USE_DRIVER_H(func)    _GrVoidDriver
  687. #endif
  688.  
  689. #if (GRXPLANES & MODE_X) && defined(WANT_TO_INCLUDE_INCOMPLETE_MODES)
  690. # define USE_DRIVER_X(func)    func
  691. #else
  692. # define USE_DRIVER_X(func)    _GrVoidDriver
  693. #endif
  694.  
  695. #if (GRXPLANES & MODE_8514A)
  696. # define USE_DRIVER_I(func)    func
  697. #else
  698. # define USE_DRIVER_I(func)    _GrVoidDriver
  699. #endif
  700.  
  701. #if (GRXPLANES & MODE_S3)
  702. # define USE_DRIVER_S(func)    func
  703. #else
  704. # define USE_DRIVER_S(func)    _GrVoidDriver
  705. #endif
  706.  
  707. #define HERC_DRIVER        1
  708. #define VGA16_DRIVER        2
  709. #define VGA256_DRIVER        3
  710. #define VGA32K_DRIVER        4
  711. #define MODE_X_DRIVER        5
  712. #define IBM_8514A_DRIVER    6
  713. #define S3_DRIVER        7
  714.  
  715.  
  716. #endif /* whole file */
  717.  
  718.